"""

A menu driven demo system.

"""


import os

def getChoice() :

    choices = """

1) Print information about a given PID
2) Test the getcurrenttime call
3) Test the getprocinfo call 
4) Exit

"""
    resp = -1

    while resp not in ['1', '2', '3', '4'] :
        print choices
        resp = raw_input("Let's Do Number: ")

    resp = int(resp)

    if resp != 3 :
        return (resp, 0)
    
    choices = """

1) Verify PID, PPID, and GID fields
2) Verify System Time field
3) Verify User Time Field
4) Verify State Field
5) Verify Child Num field
6) Verify Robustness with Bad Parameters

"""
    resp = -1
    while resp not in range(1, 7) :
        print choices
        resp = input("Let's Do Number: ")
    
    return (3, resp)


def main() :
    
    os.system("make clean; make");

    while ( 1 ) :
        choice = getChoice()
        if choice[0] == 4 :
            print "\n\nCleaning up..."
            os.system("make clean");
            print "Goodbye!\n\n"
            return
        if choice[0] == 1 :
            pid = input("Enter PID to analyze (0 for current): ")
            os.system("./printTask " + str(pid))
            continue
        if choice[0] == 2 :
            os.system("./timeTest")
            os.system(" tail -n 1 /var/log/kern.log ")
            continue
        if choice[1] == 1 :
            os.system( "./idCheck ")
        elif choice[1] == 2 :
            os.system( "./sysTime ")
        elif choice[1] == 3 :
            os.system( "./userTime ")
        elif choice[1] == 4 :
            os.system( "./stateCheck ")
        elif choice[1] == 5 :
            os.system( "./childNum " )
            
        elif choice[1] == 6 :
            os.system( "./badParams " )
        else :
            print "ERROR!!"
main()
            

        
